/*
 * @Author: szx
 * @Date: 2021-12-04 14:33:45
 * @LastEditTime: 2021-12-04 14:42:15
 * @Description:
 * @FilePath: \leetcode\1-99\24\24.js
 */
function ListNode(val, next) {
    this.val = val === undefined ? 0 : val;
    this.next = next === undefined ? null : next;
}

/**
 * @param {ListNode} head
 * @return {ListNode}
 */
var swapPairs = function (head) {
    let prev = new ListNode(-1, head);
    let curr = prev;
    while (curr.next && curr.next.next) {
        const tmp = curr.next;
        const tmp2 = curr.next.next.next;

        curr.next = curr.next.next;
        curr.next.next = tmp;
        curr = tmp;
        curr.next = tmp2;
    }
    return prev.next;
};
